<?php
header("content-type:text/html;charset=utf-8");
include_once "../lib/databases.php";
include_once "../lib/function.php";
//接收数据
$data = isset($_POST['data']) ? $_POST['data'] : "";
//判断是否接收到数据
if($data != ""){
    //组织sql语句
    $add_account = sprintf("insert account values(null,'%s','%f','%s','%s',%d,%d,'%s')",$data["type"],$data["amount"],$data["category"],$data["description"],time(),$_SESSION["user_info"]['id'],$_SESSION["user_info"]['name']);
    //执行添加语句
    $res = $db->execSql($add_account);
    if($res){
        $db->insertLog($_SESSION['user_info']['id'],$_SESSION['user_info']['name'],'add','添加财务账单');
        echo $fun->success("添加账单成功");
    }else{
        echo $fun->error("添加账单失败");
    }
}else{
    echo $fun->error("插入的信息不完整");
}